// see http://vuejs-templates.github.io/webpack for documentation.
var path = require("path");
var params = process.argv.splice(2); //获取命令中带入的参数
var subjectName = params[0]; //项目名称

var fs=require('fs');

// console.log(params);
var options = {
  subjectName: subjectName,
  build: {
    env: require("./prod.env"),
    index: path.resolve(__dirname, "../../www/dist/" + subjectName + "/index.html"),
    assetsRoot: path.resolve(__dirname, "../../www/dist/" + subjectName),
    assetsSubDirectory: "static",
    assetsPublicPath: "/dist/" + subjectName + "/",
    productionSourceMap: false,
    productionGzip: true,
    productionGzipExtensions: ["js", "css","svg","woff"],
    bundleAnalyzerReport: false
  },
  dev: {
    env: require("./dev.env"),
    port: 8080,
    vueModulePath: path.resolve( __dirname, "../src/" + subjectName + "/modules" ),
    autoOpenBrowser: false,
    assetsSubDirectory: "static",
    assetsPublicPath: "/dist/" + subjectName + "/",
    proxyUrl:"http://127.0.0.1:3000/",
    proxyTable: {}, //在下面自动设置
    cssSourceMap: false
  }
};

//自动获取代理目录
var areasDir=fs.readdirSync(path.resolve(__dirname, "../../areas"));
areasDir.map(function(dir) {
  if (!dir.startsWith(".")) {
    options.dev.proxyTable["/"+ dir]={
      target: options.dev.proxyUrl,
      changeOrigin: true
    }
  }
});
module.exports = options;
